# _*_ coding: UTF-8 _*_
# @Time     : 2021/11/1 10:41
# @Author   : Gong Yangyi
# @Site     : http://www.hzdledu.cn/
# @File     : w2.py
# @Software : PyCharm
from selenium import webdriver
import time
from selenium.webdriver.common.by import By


# 元素的操作
def foo1():
    driver = webdriver.Chrome()
    driver.maximize_window()

    driver.get('https://www.baidu.com/')

    # 模拟键盘输入
    driver.find_element_by_id('kw').send_keys('双十一特价')
    time.sleep(2)

    # 模拟鼠标左键点击输入框
    driver.find_element_by_id('su').click()
    time.sleep(3)

    #获取元素text
    text=driver.find_element_by_xpath('').text
    print()
    #获取元素属性
    #get_attribute():
    #text=获取元素文本


    # 清空输入框
    # clear:只针对<input>。建议在每次前输入先clear
    driver.find_element_by_id('kw').clear()
    driver.find_element_by_id('kw').send_keys('双十二')

if __name__=='__main__':
    foo1()
